package com.dc.system.controller;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.dc.common.constants.ConstantsCommon;
import com.dc.common.model.BaseModel;
import com.wordnik.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/system")
public class TokenController {
	/**
	 * 获取防止表单重复提交token值
	 * @Title: getToken 
	 * @param baseModel
	 * @param request
	 * @return: BaseModel
	 * @author: ShenHJ
	 * Date: 2018年4月23日 上午10:04:04
	 */
	@ApiOperation(value = "获取防止表单重复提交的token值", httpMethod = "GET")
	@RequestMapping("/getToken")
	public BaseModel getToken(BaseModel baseModel, HttpServletRequest request) {
		// 获取token
		String token = UUID.randomUUID().toString();
		// 放入session
		request.getSession().setAttribute(ConstantsCommon.TOKEN, token);
		// 放入baseModel返回给用户
		baseModel.setToken(token);
		return baseModel;
	}
}
